//
//  CTTableViewCellView.m
//  PT
//
//  Created by yate1996 on 15/6/18.
//  Copyright (c) 2015年 jarze. All rights reserved.
//

#import "CTTableViewCellView.h"
#import "MeItem.h"
#import "LabelItem.h"

@interface CTTableViewCellView ()

@property (nonatomic, weak) UILabel *teacherNameLabel;
@property (nonatomic, weak) UIImageView *teacherIconView;
@property (nonatomic, strong) UILabel *teacherScoreLabel;
@property (nonatomic, strong) UIView *rightArrowView;
@end
@implementation CTTableViewCellView

- (void)setMeItem:(MeItem *)meItem
{

    _meItem = meItem;
    
    self.teacherNameLabel.text = self.meItem.teacherName;
    
    
    self.teacherScoreLabel.text = self.meItem.teacherScore;
    
    self.teacherIconView.image = [UIImage imageNamed:self.meItem.teacherIcon];
    
    CGFloat iconX = PTRecorderCellInset;
    CGFloat iconY = PTRecorderCellInset;
    CGFloat iconW = 40;
    CGFloat iconH = 40;
    self.teacherIconView.frame = CGRectMake(iconX, iconY, iconW, iconH);
    self.teacherIconView.centerY = 68 / 2;
    
    
    CGFloat titleX = CGRectGetMaxX(self.teacherIconView.frame) + 15;
    CGFloat titleY = iconY + 5;
    NSMutableDictionary *textAttr = [NSMutableDictionary dictionary];
    textAttr[NSFontAttributeName] = PTHelveticaNeue14;
    CGSize titleSize = [self.meItem.teacherName sizeWithAttributes:textAttr];
    self.teacherNameLabel.frame = (CGRect){{titleX,titleY},titleSize};
    
    
    CGFloat nameX = titleX;
    CGFloat nameY = CGRectGetMaxY(self.teacherNameLabel.frame) + PTRecorderCellMargin * 0.7;
    textAttr[NSFontAttributeName] = PTRecorderlessonTitleFont
    titleSize = [self.meItem.teacherScore sizeWithAttributes:textAttr];
    self.teacherScoreLabel.frame = (CGRect){{nameX,nameY},titleSize};


}



-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if(self) {
        
        self.backgroundColor = [UIColor whiteColor];

        UILabel *teacherNameLabel = [[UILabel alloc]init];
        teacherNameLabel.font = PTHelveticaNeue14;
        [self addSubview:teacherNameLabel];
        self.teacherNameLabel = teacherNameLabel;
        
        UIImageView *teacherIconView = [[UIImageView alloc]init];
        [self addSubview:teacherIconView];
        self.teacherIconView = teacherIconView;
        
        UILabel *teacherScoreLabel = [[UILabel alloc]init];
        teacherScoreLabel.font = PTRecorderlessonTitleFont;
        [self addSubview:teacherScoreLabel];
        self.teacherScoreLabel = teacherScoreLabel;
        
    }
    return self;
}

@end
